ChatGPT for explanation purposes

Conditional statements:

Boolean expression: true or false
Boolean operators

Example#1: Wages.java
Input: nb of hours worked by the employee
hrs <= 40 ==> formula1
hrs > 40 ==> formula2

Example#2: Guessing.java

- Ternary operator: ? :

int val1 = 12, val2 = 13;
int max;

if(val1 > val2) {
	max = val1;
} else {
	max = val2;
}

max = (val1 > val2) ? val1 : val2;


System.out.println ("Your change is " + count + ((count == 1) ? "Dime" : "Dimes"));

Rewrite this using if-else:
System.out.print("Your change is " + count);
if(count==1){
	System.out.println(" dime.");
}else{
	System.out.println(" dimes.")
}

- Nested if:

if()
	if()

	else
else

Rule: else is matched to the closest unmatched if

if (code == ‘R’) {
	if (height <= 20)
		System.out.println(“Situation Normal”); 
} else 
		System.out.println (“Bravo”);

Example#3: MinOfThree.java














